package daobeauty.interceptor.returntype.handler.impl;

import java.util.ArrayList;
import java.util.List;

import daobeauty.interceptor.returntype.handler.ReturnTypeHandler;

/**
 * ReturnTypeHandler for methods returning an ArrayList.
 * 
 * @author M. Serhat Cinar
 *
 */
public class ArrayListReturnType implements ReturnTypeHandler<ArrayList> {

	/**
	 * Creates a new ArrayList and adds all elements of the List to the ArrayList.
	 * 
	 * @see daobeauty.interceptor.returntype.handler.ReturnTypeHandler#convert(java.util.List)
	 */
	@SuppressWarnings("unchecked")
	public ArrayList convert(List result) {
		return new ArrayList(result);
	}

	/**
	 * Creates a new ArrayList and adds the Object to the ArrayList.
	 * 
	 * @see daobeauty.interceptor.returntype.handler.ReturnTypeHandler#convert(java.lang.Object)
	 */
	@SuppressWarnings("unchecked")
	public ArrayList convert(Object result) {
		final ArrayList list = new ArrayList(1);
		list.add(result);
		return list;
	}
}
